package com.gitee.wsl.mathematics.geometry.d2

import com.gitee.wsl.io.dataproxy.DataProxy
import com.gitee.wsl.mathematics.coordinate.d2.Coordinate2
import com.gitee.wsl.mathematics.geometry.api.CloseShape
import com.gitee.wsl.mathematics.geometry.api.Shape
import com.gitee.wsl.mathematics.geometry.d2.api.ShapeContourProvider
import com.gitee.wsl.mathematics.geometry.d2.api.ShapeProvider
import com.gitee.wsl.mathematics.number.FloatCalcContainer
import com.gitee.wsl.mathematics.vector.vec2.Vec2f

interface Shape2d<N:Number,V: Coordinate2<N, V>>: Shape<N, V>,Point2Container<N,V>,
    ShapeContourProvider , ShapeProvider{

    val area: N

    val perimeter: N

    //fun containsX(x: N): Boolean
    //fun containsY(y: N): Boolean
    //fun containsBoundsXY(x: N, y: N): Boolean = containsX(x) && containsY(y)

    fun containsPoint(p: Coordinate2<N, *>): Boolean

    override fun getBounds(): CloseShape2d<N, V>

    fun createPoint2(x:N,y:N):V

    /** Returns [Shape] representation of the [LineSegment]. */
    override val shape: com.gitee.wsl.mathematics.geometry.d2.contour.ContourShape
        get() = com.gitee.wsl.mathematics.geometry.d2.contour.ContourShape(listOf(contour))
}

interface CloseShape2d<N:Number,V: Coordinate2<N, V>>: CloseShape<N, V>,Shape2d<N,V>{
    override fun getBounds() = this
}

abstract class AbstractShape(override val proxy: DataProxy<Vec2f>):Shape2d<Float,Vec2f>,FloatCalcContainer{

    override fun createPoint2(x: Float, y: Float): Vec2f = Vec2f(x,y)

}

abstract class AbstractCloseShape(override val proxy: DataProxy<Vec2f>):AbstractShape(proxy),CloseShape2d<Float,Vec2f>


